import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/layout',
    name: 'Layout',
    meta: {title: '首页'},
    component: () => import('../components/Layout'),
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        meta: {title: '欢迎体验Vue3全栈课程'},
        component: () => import('../views/Welcome.vue'),
      },
      {
        path: '/system/user',
        name: 'user',
        meta: {title: '用户管理'},
        component: () => import('../views/User.vue'),
      },
      {
        path: '/system/menu',
        name: 'menu',
        meta: {title: '菜单管理'},
        component: () => import('../views/Menu.vue'),
      },
      {
        path: '/system/role',
        name: 'role',
        meta: {title: '角色管理'},
        component: () => import('../views/Role.vue'),
      },
      {
        path: '/system/dept',
        name: 'dept',
        meta: {title: '部门管理'},
        component: () => import('../views/Dept.vue'),
      },
      {
        path: '/system/leave',
        name: 'leave',
        meta: {title: '休假管理'},
        component: () => import('../views/Leave.vue'),
      },
      {
        path: '/system/approve',
        name: 'approve',
        meta: {title: '待我审批'},
        component: () => import('../views/Approve.vue'),
      },
    ]
  },
];

const router = new VueRouter({
  routes,
});

export default router;
